package org.alis.smallcc.designpatterns.behavior.iterator;

public class Main {
	public static void main(String[] args) {
		Aggregate<Node> array=new  ArrayAggregate<>();
		Node node = new Node("什么呀");
		array.add(node);
		array.add(new Node("做咩呀"));
		array.add(new Node("想啥呀"));
		array.add(new Node("干哈呀"));
		array.add(new Node("好屁呀"));
		array.add(new Node("xx呀"));
		Iterator<Node> iterator = array.iterator();
//		while(iterator.hasNext()) {
//			System.out.println(iterator.next());
//		}
		System.out.println(array.remove(1)+"已删除");
		array.forEach(System.out::println);
	}

}

class Node {
	private String name;

	public Node(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "节点名称是" + name;
	}
}